#ifndef THINK_THINK_PROCESS_EXCEPTION_TIMEOUT_H
#define THINK_THINK_PROCESS_EXCEPTION_TIMEOUT_H

static char* think_process_exception_timeout =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: yunwuxin <448901948@qq.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think\\process\\exception;\n"
	"\n"
	"use think\\Process;\n"
	"\n"
	"class Timeout extends \\RuntimeException\n"
	"{\n"
	"\n"
	"    const TYPE_GENERAL = 1;\n"
	"    const TYPE_IDLE    = 2;\n"
	"\n"
	"    private $process;\n"
	"    private $timeoutType;\n"
	"\n"
	"    public function __construct(Process $process, $timeoutType)\n"
	"    {\n"
	"        $this->process     = $process;\n"
	"        $this->timeoutType = $timeoutType;\n"
	"\n"
	"        parent::__construct(sprintf(\'The process \"%s\" exceeded the timeout of %s seconds.\', $process->getCommandLine(), $this->getExceededTimeout()));\n"
	"    }\n"
	"\n"
	"    public function getProcess()\n"
	"    {\n"
	"        return $this->process;\n"
	"    }\n"
	"\n"
	"    public function isGeneralTimeout()\n"
	"    {\n"
	"        return $this->timeoutType === self::TYPE_GENERAL;\n"
	"    }\n"
	"\n"
	"    public function isIdleTimeout()\n"
	"    {\n"
	"        return $this->timeoutType === self::TYPE_IDLE;\n"
	"    }\n"
	"\n"
	"    public function getExceededTimeout()\n"
	"    {\n"
	"        switch ($this->timeoutType) {\n"
	"            case self::TYPE_GENERAL:\n"
	"                return $this->process->getTimeout();\n"
	"\n"
	"            case self::TYPE_IDLE:\n"
	"                return $this->process->getIdleTimeout();\n"
	"\n"
	"            default:\n"
	"                throw new \\LogicException(sprintf(\'Unknown timeout type \"%d\".\', $this->timeoutType));\n"
	"        }\n"
	"    }\n"
	"}\n"
	"\n"
;
#endif